<include file="../Public/header" />
<!--<script src="__APP__/js/iscroll-lite.js"></script>-->
<div id="content" data-title="消息盒子" class="content">
    <menu id="msgmenu">
        <div class="pure-menu pure-menu-open">
            <ul>
                <li class="header">New</li>
                <li><a href="#new-weibo">新分享</a></li>
                <li class="header">Apps</li>
                <li><a href="{:U('w3g/Index/index')}">分享</a></li>
                <li class="pure-menu-selected"><a href="{:U('w3g/Index/msgbox')}">消息盒子</a></li>
                <li><a href="{:U('w3g/Public/log_out')}">退出</a></li>
            </ul>
        </div>
    </menu>
    <div id="msgdetail" data-title="与{$r['to'][0]['user_info']['uname']}的对话" date-selected="true">
        <header>
            <div id="header-buttons">
                <a href="{:U('w3g/Index/msgbox')}#msg">
                    <div id="back" class="header-menu-link" data-back="false">
                    </div>
                </a>

                <!--<div id="messageLink" class="header-menu-link"><a href="{:U('w3g/Index/msgbox')}"><i class="num"></i></a></div>-->
        <div id="menuLink" class="header-menu-link"></div>
            </div>
            <h1 class="hasback">
                与{$r['to'][0]['user_info']['uname']}的对话
            </h1>
        </header>
        <div id="msgdetaillist" style="height: 300px;width: 100%;overflow: hidden;">
            <div id="msgdetaillist-scrollarea">
                <php>
                    foreach($r['data'] as $index=>$item){
                        if($profile['uid'] !== $item['from_uid']){
                            $conversation_item_class = 'conversation-item-left';
                            $user_cache = $r['member'][0];
                        }else{
                            $conversation_item_class = 'conversation-item-right';
                            $user_cache = $r['member'][1];
                        }
                </php>
                <div class="conversation-item {$conversation_item_class}">
                    <div class="conversation-item-head">
                        <img src="{$user_cache['user_info']['avatar_small']}" alt="{$user_cache['user_info']['uname']}"/>
                    </div>
                    <div class="conversation-item-content">
                        <!--<div class="conversation-item-info">{$user_cache['user_info']['uname']} <span class="time">{$item['mtime']}</span></div>-->
                        <div class="conversation-item-content-content">{:wapFormatContent($item['content'])}</div>
                    </div>
                </div>
                <php>
                    }
                </php>
            </div>
        </div>
        <custom>
            <div id="conversation-toolbar">
                <div class="pure-form">
                    <input type="send" id="conversation-toolbar-input"/>
                    <button id="conversation-toolbar-post" class="pure-button conversation-toolbar-btn ts-listen" data-listen="weibo-postmessage-{$r['to'][0]['member_uid']}">发送</button>
                </div>
            </div>
        </custom>
        <script>
            /*var resizeConversationToolbar = function(){
                var postbtnWidth = Number($('#custom').find('#conversation-toolbar-post').width());
                var boxWidth = Number($('#custom').find('#conversation-toolbar .pure-form').width()) - Number($('#custom').find('#conversation-toolbar').css('padding-left').replace('px',''))*2-4;
                $('#custom').find('#conversation-toolbar-input').width(boxWidth-postbtnWidth);
                window.scrollTo(0,document.body.scrollHeight);
            }
            window.onresize = function(){resizeConversationToolbar()};*/
            $(function(){
                //移除预先高度设置
                $('#content').removeAttr('style');
                window.setTimeout(function(){
                    //设置iScroll
                    var msgDetailList = $('#msgdetaillist');
                    //设定消息列表高度
                    msgDetailList.height($(window).height()-48-54);
                    //初始化iScroll
                    $.ui.cache.msgDetailListScroll = new IScroll('#msgdetaillist',{
                        mouseWheel: true,
                        scrollbars: true
                    });
					$.ui.cache.msgDetailListScroll.scrollToElement($($.ui.cache.msgDetailListScroll.wrapper).find('div:first>div:last').get(0),1);
                },100);
                //如果是乔老爷的iOS系统，嗯，得搞搞
				//?↑while[2015-05-21] 搞啥，咋搞
                if($.os.ios){
                    //do nothing
                }
            });
        </script>
    </div>
    <include file="../Public/footer" />